package com.pastquestion;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main10h {
	static int[] X = new int[] {1,0,0,-1};
	static int[] Y = new int[] {0,-1,1,0};
	static String[] d = {"D","L","R","U"};
	static int[][] graph = new int[31][51];
	static boolean[][] visited = new boolean[31][51];
	static Node ans = new Node(0,0,"",Integer.MAX_VALUE);
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\shuoye\\Desktop\\pullze.txt")));
		for (int i = 1; i < 31; i++) {
			char[] a = reader.readLine().toCharArray();
			for (int j = 0; j < a.length; j++) {
				graph[i][j + 1] = Integer.parseInt("" + a[j]);
			}
			
		}
		bfs();
		System.out.println(ans.step + "  " + ans.path);
	}
	
	public static void bfs() {
		Queue<Node> qu = new LinkedList<>();
		qu.add(new Node(1,1,"",0));
		visited[1][1] = true;
		while(!qu.isEmpty()) {
			Node no = qu.poll();
			visited[no.x][no.y] = true;
			if(no.x == 30 && no.y == 50) {
				ans = ans.step < no.step ? ans : no;
			}
			for(int i = 0;i < 4;i++) {
				int newx = no.x + X[i];
				int newy = no.y + Y[i];
				if(checked(newx,newy)) {
					qu.add(new Node(newx,newy,no.path + d[i],no.step+1));
				}	
			}
		}
	}
	
	public static boolean checked(int x,int y) {
		if(x > 30 || x < 1 || y < 1 || y > 50)
			return false;
		if(visited[x][y] || graph[x][y] == 1)
			return false;
		return true;
	}
}


class Node{
	int x;
	int y;
	String path;
	int step;
	
	public Node() {};
	
	public Node(int x,int y,String path,int step){
		this.x = x;
		this.y = y;
		this.path = path;
		this.step = step;
	}
}